<template>
	<view class="wrapper">
		<!-- 空白页-->
		<view  class="empty" v-if="!flag">
			<image src="/static/emptyCart.png" mode="aspectFit"></image>
			<view class="empty-tips">
				空空如也
				<navigator class="navigator" url="/pages/tabbar/home/index" open-type="switchTab">随便逛逛></navigator>
			</view>
		</view>

		<!-- 店铺商品信息 -->
		<view class="content" v-if="flag">
			<view class="box box2" v-for="(item, index) in 1" :key="index">
				<view class="tab">
					<view class="store-line">
						<!-- 选择框 -->
						<u-checkbox-group class="store-line-check">
							<u-checkbox shape="circle" :active-color="lightColor"
								@change="checkboxChangeDP()"></u-checkbox>
						</u-checkbox-group>
						<!-- title -->
						<view @click.stop="navigateToStore()">
							<span class="store-name wes store-line-desc" >店铺名称</span>
							<u-icon  size="24" style="margin-left:10rpx;" name="arrow-right"></u-icon>
						</view>
					</view>
				</view>

				<u-swipe-action  @open="openAction()" :options="options" bg-color="#fff"
					ref="swiperAction" class="cart-item" v-for="(skuItem, i) in 2" :index="i" :key="i"
					@click="changeActionTab()" @longpress="changeActionTab()">

					<view class="goods-row">
						<view class="goods-content">
							<view class="goods-content-img">
								<image src="https://l.b2b168.com/2017/07/28/13/201707281344182879554.jpg" mode=""></image>
							</view>
							<view>
								<!-- 商品名称 -->
								<p class="sp-name" @click="navigateToGoods()">
									我是商品名称
								</p>
								<!-- 规格 -->
								<p class="sp-type">我是商品详情</p>
								<p class="sp-number">
									<view class="sp-price">
										<view class="main-color">
											￥<span>123</span>
											<span>.11</span>
										</view>
									</view>
									<view>
										<uni-number-box class="uNumber" :min="1" :max="999" v-model="skuItem.num">
										</uni-number-box>
									</view>
								</p>
							</view>
						</view>
					</view>
				</u-swipe-action>
			</view>
			<view style="width: 100%; height: 100rpx;"></view>
		</view>
		<u-modal v-model="deleteShow" :confirm-style="{'color':lightColor}" @confirm="deleteConfirm" show-cancel-button
			:content="deleteContent" :async-close="true"></u-modal>
		<!-- 结账 -->
		<view class="box box6">
			<view class="navL">
				<u-checkbox shape="circle" :active-color="lightColor" v-model="checkout" @change="checkOut()"
					label-size="24">全选
				</u-checkbox>
				<span class="price">
					<view class="prices">
						<view class="fullPrice">
							<span class="number">总计:0.00</span>
						</view>
					</view>
				</span>
			</view>
			<view @click="submitOrder()">
				<view class="settlement">去结算</view>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>
<script>
	import uniNumberBox from '@/components/uni-number-box'
	export default {
		components: {
			uniNumberBox // 数量加减组件
		},
		data() {
			return {
				deleteShow: false, //右滑删除
				deleteContent: "删除该商品？", //删除显示的信息
				// 商品栏右侧滑动按钮
				options: [{
					text: "删除",
					style: {
						backgroundColor: this.$lightColor, //高亮颜色
					},
				}, ],
				checkout: false, //全选按钮
				lightColor: this.$lightColor,
				flag:true ,// 控制有无数据,
				
			};
		},


		methods: {
			/**
			 * 跳转到店铺
			 */
			navigateToStore(val) {
				uni.navigateTo({
					url: "/pages/product/shopPage",
				});
			},

			/**
			 * 店铺点击
			 */
			checkboxChangeDP(e) {
				console.log('点击了店铺')
			},

			/**
			 * 左滑打开删除
			 */
			openAction(skuItem) {
				console.log('删除店铺')
			},

			/**
			 * 滑动删除
			 */
			changeActionTab(val) {
				this.deleteShow = true;
			},

			/**
			 * 点击删除
			 */
			deleteConfirm() {
				uni.showToast({
					title: "此商品删除成功",
					duration: 2000,
				});

				this.deleteShow = false;
			},

			/**
			 * 去结算
			 */
			submitOrder() {
				uni.navigateTo({
					url: "/pages/order/fillorder"
				});
			},

			/**
			 * 全选
			 */
			checkOut() {
				console.log('全选')
			},

			/**
			 * 跳转到商品
			 */
			navigateToGoods(val) {
				uni.navigateTo({
					url: "/pages/product/goods"
				});
			},


		},
	};
</script>

<style lang="scss">
	page {
		background: #f2f2f2;
	}
</style>
<style scoped lang="scss">
	// #ifdef MP-WEIXIN
	@import "./mp-carui.scss";

	// #endif
	.u-image {
		box-shadow: 0 4rpx 12rpx 0 rgba(0, 0, 0, 0.05);
	}


	.store-name {
		font-weight: bold;
		font-size: 28rpx;
	}

	.cart-item {
		border-radius: 0.4em;
		transition: 0.35s;
	}

	/* 空白页 */
	/deep/ .u-number-input {
		background: #fff !important;
		border: 1px solid #ededed;
		margin: 0 !important;
	}

	/deep/ .u-icon-minus,
	/deep/ .u-icon-plus {
		background: #ffffff !important;
		border: 1px solid #ededed;
		color: #333 !important;
		width: 40rpx;
	}

	.empty {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100vh;
		z-index: 99;
		padding-bottom: var(--window-bottom);
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
		background: #fff;

		image {
			width: 240rpx;
			height: 160rpx;
			margin-bottom: 30rpx;
		}

		.empty-tips {
			display: flex;
			font-size: $font-sm + 2rpx;
			color: $font-color-disabled;

			.navigator {
				color: $uni-color-primary;
				margin-left: 16rpx;
			}
		}
	}

	.settlement {
		width: 180rpx;
		height: 70rpx;
		line-height: 70rpx;
		background: linear-gradient(91deg, $light-color 1%, $aider-light-color 99%);
		border-radius: 900rpx;
		text-align: center;
		color: #fff;
		margin-right: 10rpx;
	}

	.price {
		display: flex;
		align-items: center;

		/deep/ .number {
			line-height: 1;
			font-size: 30rpx;

			>span {
				font-weight: bold;
			}
		}
	}

	.box2 {
		border-radius: 20rpx;
		padding: 0 16rpx 0;
		margin: 0 16rpx 20rpx;

		.u-checkbox {
			display: flex;
			align-items: center;
			text-align: center;
		}

		background: #fff;

	}

	.wrapper {
		height: 100%;
	}

	/deep/ .u-col {
		padding: 24rpx 0 !important;
	}

	.goods-content {
		display: flex;
		width: 100%;
		height: 100%;
		overflow: hidden;
		
		&-img {
			width: 180rpx;
			height:150rpx;
			margin-right: 20rpx;
			
			image {
				width: 100%;
				height: 100%;
			}
		}

		>p {
			padding-left: 20rpx;
		}
	}

	.content {
		padding: 20rpx 0 20rpx 0;
		margin-bottom: 80rpx;
	}


	.store-line-check,
	.store-line-img,
	.store-line-desc {
		// #ifdef MP-WEIXIN
		float: left;
		// #endif
	}

	.store-line {
		// #ifndef MP-WEIXIN
		display: flex;
		// #endif
		overflow: hidden;
		flex: 10;
	}



	.tab {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 30rpx 0 0 0;
	}

	.box6 {
		justify-content: space-between;
		position: fixed;
		// #ifdef APP-PLUS || MP-WEIXIN
		bottom: 0;
		// #endif
		// #ifdef H5
		bottom: var(--window-bottom);
		// #endif
		left: 0;
		border-top: 1px solid #ededed;
		display: flex;
		height: 100rpx;
		overflow: hidden;
		align-items: center;
		width: 100%;
		background: rgba(255, 255, 255, 1);
		color: #333;
		z-index: 99;

		>.navL {
			padding: 0 32rpx;
			display: flex;
			align-items: center;
		}
	}

	.sp-type {
		color: $u-light-color;
		padding: 10rpx 0;
		font-size: 24rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		width: 460rpx;
	}

	.sp-number {
		width: 460rpx;
		font-weight: bold;
		display: flex;
		justify-content: space-between;

		>.sp-price {
			/deep/ span:nth-of-type(1) {
				font-size: 38rpx;
			}

			/deep/ span:nth-of-type(2) {
				font-size: 24rpx;
			}
		}
	}

	.prices {
		display: flex;
		flex-direction: column;

		>.discountPrice {
			align-items: center;
			display: flex;
			font-size: 24rpx;
			color: rgb(201, 199, 199);
		}
	}
	
	.goods-row {
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}
</style>
